IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'CreatorGetBySaga')
	BEGIN
		DROP  Procedure  CreatorGetBySaga
	END

GO

CREATE Procedure CreatorGetBySaga
@CreatorID Int,
@SagaID Int
AS
Select
c.CreatorID,
asp.UserName,
coalesce(sr.RoleName,'Browser') AS RoleName,
coalesce(sc.SagaRoleID,1) AS SagaRoleID
From Creator c
Left Join SagaCreators sc On sc.CreatorID = c.CreatorID
Left Join SagaRoles sr On sr.SagaRoleID = sc.SagaRoleID
Join aspnet_Users asp On asp.UserID = c.UserID
Where c.CreatorID = @CreatorID




GO


